<?php

Class PostDao extends  CI_Model{

	public function PostDao(){
		parent::__construct();
		$this->load->database();
		$this->load->model('dto/PostDto');
	}

	public function listPost(PostDto $post){
		$this->db->select('post_id,post_title,tbpost.cat_id,tbpost.user_id,post_image,post_content,post_date , tbuser.user_name , tbcategory.cat_name');
		$this->db->from('tbpost');
		$this->db->join('tbuser' , 'tbuser.user_id = tbpost.user_id');
		$this->db->join('tbcategory' , 'tbcategory.cat_id = tbpost.cat_id');
		$array = array('post_id' => $post->getPostid() , 'post_title' => $post->getTitle() , 'tbcategory.cat_name' => $post->getCategoryname());
		$this->db->like($array );
		$query = $this->db->get();
		$result = $query->result();
		return $result;
	}

}